package cn.sinata.wanglin.village.fragment;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.xilada.xldutils.fragment.BaseLazyFragment;
import com.xilada.xldutils.utils.ActivityUtil;
import com.xilada.xldutils.utils.Utils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import cn.sinata.wanglin.R;
import cn.sinata.wanglin.adapter.CelldynameicesPagerAdapter;
import cn.sinata.wanglin.commonutils.FragmentAdapter;

/**
 * description：小区---小区动态
 * Created by kaihongwu on 2016/12/06 上午 9:45
 */
public class CelldynamicsFragment extends BaseLazyFragment {
    @BindView(R.id.viewpager_village)
    ViewPager viewpager;//
    @BindView(R.id.tabs_village)
    TabLayout tabs;//
    private  CelldynameicesPagerAdapter mPagerAdapter;
    @Override
    protected int getContentViewLayoutID() {
        return R.layout.fragment_celldynamics;
    }

    @Override
    protected void onFirstVisibleToUser() {

        setupViewPager();
    }

    @Override
    protected void onVisibleToUser() {

    }

    @Override
    protected void onInvisibleToUser() {

    }
    private void setupViewPager() {
            ArrayList<String> titles = new ArrayList<>();
            titles.add("吐槽");
            titles.add("活动");
            Utils.systemErr("---小区动态---");
            mPagerAdapter = new CelldynameicesPagerAdapter(getChildFragmentManager(), titles);
            viewpager.setAdapter(mPagerAdapter);
            tabs.setupWithViewPager(viewpager);
    }

    public void setCurrentTab(int type){
        //吐槽0，活动1；
        if(viewpager!=null){
            viewpager.setCurrentItem(type);
            mPagerAdapter.notifyDataSetChanged();
        }
    }

}
